A number is positive if it is greater than zero, negative if it is less than zero, and zero if it is equal to zero.
def check_number(num):
if num > 0:
return "Positive"
elif num < 0:
return "Negative"
else:
return "Zero"
# Taking input for the number and checking its sign
def check_and_display_number_sign():
num = float(input("Enter a number: "))
sign = check_number(num)
print("The number is", sign)
check_and_display_number_sign()
Enter a number: 5
The number is Positive
Enter a number: -2
The number is Negative
Enter a number: 0
The number is Zero
The function check_number(num)
checks whether a given number is positive, negative, or zero, and returns the corresponding string.
The function check_and_display_number_sign()
takes input for the number, checks its sign using the aforementioned function, and displays the result.